//  @ Project : SPPager
//  @ File Name : IPageList.cs
//  @ Date : 2013/6/5
//  @ Author : yubaolee(.cpp)
//  @ Description: 

using System.Collections.Generic;
namespace LYB.NET.SPPager
{
    public interface IPageList
    {
        int CurrentPageIndex { get; set; }
        int PageSize { get; set; }
        int TotalPageCount { get; }
        int TotalRecordCount { get; }
    }

    public class PageList<T> : List<T>, IPageList
    {
        public int CurrentPageIndex { get; set; }

        public int PageSize { get; set; }

        public int TotalRecordCount { get; set; }

        public int TotalPageCount 
        { 
            get
            {
                if (TotalRecordCount == 0)
                    return 1;

                if (TotalRecordCount % PageSize == 0)
                    return (TotalRecordCount / PageSize);

                return (TotalRecordCount / PageSize + 1);
            } 
        }

        public PageList(IList<T> items, int pagesize, int index, int totalrecordcount)
        {
            AddRange(items);
            PageSize = pagesize;
            CurrentPageIndex = index;
            TotalRecordCount = totalrecordcount;
        }

    }
}
